'use strict';

module.exports = app => {
  const { ENUM, INTEGER } = app.Sequelize;
  // 佣金日志
  const CommissionLog = app.model.define('commissionLog', {
    // 佣金
    commission: { type: INTEGER, allowNull: false, defaultValue: 0 },
    // 佣金发放状态
    status: {
      type: ENUM,
      values: [ 'pending', 'success' ],
      allowNull: false,
      defaultValue: 'pending',
    },
  });

  CommissionLog.associate = function() {
    // 订单
    CommissionLog.belongsTo(app.model.Order);
    // 用户
    CommissionLog.belongsTo(app.model.User);
  };

  return CommissionLog;
};
